clear
load OAFig2data
labels = {'Agr.,Mining, Fishing','Construction','Manufacturing','Service','Unemployed','Outside','Others'};

explode = [0 0 1 1 0 0 0 ];


ax1 = subplot(1,2,1);
h1=pie(ax1,exp_10511(:,2));

%%%for putting the labels inside
for iHandle = 2:2:2*numel(labels)
    h1(iHandle).Position = 0.5*h1(iHandle).Position;
end

hp = findobj(h1, 'Type', 'patch');
set(hp(1), 'FaceColor', [1 0.6 1], 'EdgeColor',[0 0 0], 'LineStyle',':', 'LineWidth',1);

set(hp(2), 'FaceColor', [0.4 0.8 0.9], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2);
set(hp(3), 'FaceColor', [0.9 0.9 0.9], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2);
set(hp(4), 'FaceColor', [0.2 0.43 0.2], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp(5), 'FaceColor', [0.2 0.2 0.8], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp(6), 'FaceColor', [0.5 0.5 0.5], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp(7), 'FaceColor', [0 0 0], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 

thresh = 4; %do not show less than 4 %
tmp = round(exp_10511(:,2)') <= thresh; %round to nearest percentage to get rid
tmp = reshape([tmp;zeros(1,length(tmp))],1,[]);
delete(h1([find(tmp)+1]));

title(ax1,'Treated');

t = h1(6);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';


t = h1(8);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';


t = h1(12);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';





ax2 = subplot(1,2,2);
h2=pie(ax2,nonexp_10511(:,2));

%%%for putting the labels inside
for iHandle = 2:2:2*numel(labels)
    h2(iHandle).Position = 0.5*h2(iHandle).Position;
end

hp2 = findobj(h2, 'Type', 'patch');
set(hp2(1), 'FaceColor', [1 0.6 1], 'EdgeColor',[0 0 0], 'LineStyle',':', 'LineWidth',1);
set(hp2(2), 'FaceColor', [0.4 0.8 0.9], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2);
set(hp2(3), 'FaceColor', [0.9 0.9 0.9], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2);
set(hp2(4), 'FaceColor', [0.2 0.43 0.2], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp2(5), 'FaceColor', [0.2 0.2 0.8], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp2(6), 'FaceColor', [0.5 0.5 0.5], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
set(hp2(7), 'FaceColor', [0 0 0], 'EdgeColor',[0 0 0], 'LineStyle','-', 'LineWidth',2); 
title(ax2,'Control');


tmp = round(nonexp_10511(:,2)') <= thresh; %round to nearest percentage to get rid
tmp = reshape([tmp;zeros(1,length(tmp))],1,[]);
delete(h2([find(tmp)+1]));


t = h2(6);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';


t = h2(8);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';


t = h2(12);
t.BackgroundColor = [1 1 1];
t.FontSize = 14;
t.FontName = 'TimesNewRoman';


legend(labels,'Orientation','Horizontal', 'Location','south')


% in order to convert the figure to black and white textured version as in the paper
% you need to download two matlab functions
% "applyhatch.m" and "makehatch.m" from https://www.mathworks.com/matlabcentral/fileexchange/
% and use the following command:

% applyhatch(gcf, '\x.\+-\x/|')




